package com.itheima.test2;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.util.Arrays;

/*
读取文件 排序后重新存储
 */
public class Test06 {

    public static void main(String[] args) throws Exception {
        //输入流
        BufferedReader reader = new BufferedReader(new FileReader("day13\\number.txt"));
        //读
        String s = reader.readLine();
        String[] numberStrs = s.split(" ");
        int[] arr = new int[numberStrs.length];
        for (int i = 0; i < arr.length; i++) {
            arr[i]= Integer.parseInt(numberStrs[i]);
        }
        //排序
        Arrays.sort(arr);

        //输出流
        BufferedWriter writer = new BufferedWriter(new FileWriter("day13\\number.txt",true));
        //写
        for (int i : arr) {
            writer.write(i+" ");
        }

        //释放资源
        reader.close();
        writer.close();
    }


}
